{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\myogo\Princeton Dropbox\Motohiro Yogo\Koijen Yogo - International\JPE\Replication\Code\1 Data\IMF_IFS.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}31 Oct 2025, 09:17:05
{txt}
{com}. /* Define local and global variables */
> 
> local directory = "../../Data/IMF/IFS";
{txt}
{com}. do global;
{txt}
{com}. /* global.do (STATA)
>         Define global variables in "Data".
>         by Ralph Koijen & Motohiro Yogo */
. 
. #delimit ;
{txt}delimiter now ;
{com}. clear all;
{res}{txt}
{com}. global year_min = 2003;
{txt}
{com}. global year_max = 2020;
{txt}
{com}. global small = 5e-4;
{txt}
{com}.         /* Minimum reportable threshold for CPIS */

{txt}end of do-file

{com}. /* Step 1: Construct national accounts data */
> 
> /* Load data */
> 
> u Country_Code Indicator_Code Attribute _`=$year_min-1'-_`=$year_max+1'
>         if regexm(Indicator_Code,"^(NCP_R_XDC|NCP_XDC|NGDP_D_IX|NGDP_R_XDC|NGDP_XDC)$")
>         & Attribute=="Value"
>         using `directory'/IFS_06-26-2023, clear;
{txt}
{com}. drop Attribute _*Q* _*M*;
{txt}
{com}. /* Fix variables */
> 
> destring Country_Code _*, replace;
{txt}Country_Code already numeric; no {res}replace
{txt}_2002 already numeric; no {res}replace
{txt}_2003 already numeric; no {res}replace
{txt}_2004 already numeric; no {res}replace
{txt}_2005 already numeric; no {res}replace
{txt}_2006 already numeric; no {res}replace
{txt}_2007: all characters numeric; {res}replaced {txt}as {res}double
{txt}(141 missing values generated)
{res}{txt}_2008: all characters numeric; {res}replaced {txt}as {res}double
{txt}(122 missing values generated)
{res}{txt}_2009: all characters numeric; {res}replaced {txt}as {res}double
{txt}(119 missing values generated)
{res}{txt}_2010: all characters numeric; {res}replaced {txt}as {res}double
{txt}(80 missing values generated)
{res}{txt}_2011: all characters numeric; {res}replaced {txt}as {res}double
{txt}(75 missing values generated)
{res}{txt}_2012 already numeric; no {res}replace
{txt}_2013 already numeric; no {res}replace
{txt}_2014: all characters numeric; {res}replaced {txt}as {res}double
{txt}(41 missing values generated)
{res}{txt}_2015 already numeric; no {res}replace
{txt}_2016 already numeric; no {res}replace
{txt}_2017 already numeric; no {res}replace
{txt}_2018 already numeric; no {res}replace
{txt}_2019 already numeric; no {res}replace
{txt}_2020 already numeric; no {res}replace
{txt}_2021 already numeric; no {res}replace
{txt}
{com}. /* Reshape in long format */
> 
> reshape long _, i(Country_Code Indicator_Code) j(year);
{txt}(j = 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021)

Data{col 36}Wide{col 43}->{col 48}Long
{hline 77}
Number of observations     {res}         830   {txt}->   {res}16,600      
{txt}Number of variables        {res}          22   {txt}->   {res}4           
{txt}j variable (20 values)                    ->   {res}year
{txt}xij variables:
                  {res}_2002 _2003 ... _2021   {txt}->   {res}_
{txt}{hline 77}

{com}. reshape wide _, i(Country_Code year) j(Indicator_Code) string;
{txt}(j = NCP_R_XDC NCP_XDC NGDP_D_IX NGDP_R_XDC NGDP_XDC)

Data{col 36}Long{col 43}->{col 48}Wide
{hline 77}
Number of observations     {res}      16,600   {txt}->   {res}3,940       
{txt}Number of variables        {res}           4   {txt}->   {res}7           
{txt}j variable (5 values)    {res}Indicator_Code   {txt}->   (dropped)
xij variables:
                                      {res}_   {txt}->   {res}_NCP_R_XDC _NCP_XDC ... _NGDP_XDC
{txt}{hline 77}

{com}. /* Rename variables */
> 
> foreach var in NCP_R_XDC NCP_XDC NGDP_D_IX NGDP_R_XDC NGDP_XDC {c -(};
{txt}  2{com}.         rename _`var' `var';
{txt}  3{com}. {c )-};
{res}{txt}
{com}. /* Convert to LCU billion */
> 
> foreach var of varlist NCP_R_XDC NCP_XDC NGDP_R_XDC NGDP_XDC {c -(};
{txt}  2{com}.         replace `var' = `var'/1e9;
{txt}  3{com}. {c )-};
{txt}(2,324 real changes made)
(2,573 real changes made)
(3,151 real changes made)
(3,449 real changes made)

{com}. /* Save data */
> 
> tempfile IMF_IFS;
{txt}
{com}. save `IMF_IFS';
{txt}{p 0 4 2}
file {bf}
C:\Users\myogo\AppData\Local\Temp\ST_9840_000001.tmp{rm}
saved
as .dta format
{p_end}

{com}. /* Step 2: Construct financial data */
> 
> /* Load data */
> 
> u Country_Code Indicator_Code Attribute _`=$year_min-1'-_`=$year_max+1'M12
>         if regexm(Indicator_Code,"^(ENDE_XDC_USD_RATE|FIGB_PA|FITB_PA|FPOLM_PA|PCPI_IX)$")
>         & Attribute=="Value"
>         using `directory'/IFS_06-26-2023, clear;
{txt}
{com}. keep Country_Code Indicator_Code _*Q* _*M*;
{txt}
{com}. /* Fix variables */
> 
> destring Country_Code _*, replace;
{txt}Country_Code already numeric; no {res}replace
{txt}_2002Q1 already numeric; no {res}replace
{txt}_2002M1 already numeric; no {res}replace
{txt}_2002M2 already numeric; no {res}replace
{txt}_2002M3 already numeric; no {res}replace
{txt}_2002Q2 already numeric; no {res}replace
{txt}_2002M4 already numeric; no {res}replace
{txt}_2002M5 already numeric; no {res}replace
{txt}_2002M6 already numeric; no {res}replace
{txt}_2002Q3 already numeric; no {res}replace
{txt}_2002M7 already numeric; no {res}replace
{txt}_2002M8 already numeric; no {res}replace
{txt}_2002M9 already numeric; no {res}replace
{txt}_2002Q4 already numeric; no {res}replace
{txt}_2002M10 already numeric; no {res}replace
{txt}_2002M11 already numeric; no {res}replace
{txt}_2002M12 already numeric; no {res}replace
{txt}_2003Q1 already numeric; no {res}replace
{txt}_2003M1 already numeric; no {res}replace
{txt}_2003M2 already numeric; no {res}replace
{txt}_2003M3 already numeric; no {res}replace
{txt}_2003Q2 already numeric; no {res}replace
{txt}_2003M4 already numeric; no {res}replace
{txt}_2003M5 already numeric; no {res}replace
{txt}_2003M6 already numeric; no {res}replace
{txt}_2003Q3 already numeric; no {res}replace
{txt}_2003M7 already numeric; no {res}replace
{txt}_2003M8 already numeric; no {res}replace
{txt}_2003M9 already numeric; no {res}replace
{txt}_2003Q4 already numeric; no {res}replace
{txt}_2003M10 already numeric; no {res}replace
{txt}_2003M11 already numeric; no {res}replace
{txt}_2003M12 already numeric; no {res}replace
{txt}_2004Q1 already numeric; no {res}replace
{txt}_2004M1 already numeric; no {res}replace
{txt}_2004M2 already numeric; no {res}replace
{txt}_2004M3 already numeric; no {res}replace
{txt}_2004Q2 already numeric; no {res}replace
{txt}_2004M4 already numeric; no {res}replace
{txt}_2004M5 already numeric; no {res}replace
{txt}_2004M6 already numeric; no {res}replace
{txt}_2004Q3 already numeric; no {res}replace
{txt}_2004M7 already numeric; no {res}replace
{txt}_2004M8 already numeric; no {res}replace
{txt}_2004M9 already numeric; no {res}replace
{txt}_2004Q4 already numeric; no {res}replace
{txt}_2004M10 already numeric; no {res}replace
{txt}_2004M11 already numeric; no {res}replace
{txt}_2004M12 already numeric; no {res}replace
{txt}_2005Q1 already numeric; no {res}replace
{txt}_2005M1 already numeric; no {res}replace
{txt}_2005M2 already numeric; no {res}replace
{txt}_2005M3 already numeric; no {res}replace
{txt}_2005Q2 already numeric; no {res}replace
{txt}_2005M4 already numeric; no {res}replace
{txt}_2005M5 already numeric; no {res}replace
{txt}_2005M6 already numeric; no {res}replace
{txt}_2005Q3 already numeric; no {res}replace
{txt}_2005M7 already numeric; no {res}replace
{txt}_2005M8 already numeric; no {res}replace
{txt}_2005M9 already numeric; no {res}replace
{txt}_2005Q4 already numeric; no {res}replace
{txt}_2005M10 already numeric; no {res}replace
{txt}_2005M11 already numeric; no {res}replace
{txt}_2005M12 already numeric; no {res}replace
{txt}_2006Q1 already numeric; no {res}replace
{txt}_2006M1 already numeric; no {res}replace
{txt}_2006M2 already numeric; no {res}replace
{txt}_2006M3 already numeric; no {res}replace
{txt}_2006Q2 already numeric; no {res}replace
{txt}_2006M4 already numeric; no {res}replace
{txt}_2006M5 already numeric; no {res}replace
{txt}_2006M6 already numeric; no {res}replace
{txt}_2006Q3 already numeric; no {res}replace
{txt}_2006M7 already numeric; no {res}replace
{txt}_2006M8 already numeric; no {res}replace
{txt}_2006M9 already numeric; no {res}replace
{txt}_2006Q4 already numeric; no {res}replace
{txt}_2006M10 already numeric; no {res}replace
{txt}_2006M11 already numeric; no {res}replace
{txt}_2006M12 already numeric; no {res}replace
{txt}_2007Q1: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1440 missing values generated)
{res}{txt}_2007M1: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1463 missing values generated)
{res}{txt}_2007M2 already numeric; no {res}replace
{txt}_2007M3 already numeric; no {res}replace
{txt}_2007Q2 already numeric; no {res}replace
{txt}_2007M4 already numeric; no {res}replace
{txt}_2007M5 already numeric; no {res}replace
{txt}_2007M6 already numeric; no {res}replace
{txt}_2007Q3 already numeric; no {res}replace
{txt}_2007M7 already numeric; no {res}replace
{txt}_2007M8 already numeric; no {res}replace
{txt}_2007M9 already numeric; no {res}replace
{txt}_2007Q4 already numeric; no {res}replace
{txt}_2007M10 already numeric; no {res}replace
{txt}_2007M11 already numeric; no {res}replace
{txt}_2007M12 already numeric; no {res}replace
{txt}_2008Q1: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1441 missing values generated)
{res}{txt}_2008M1: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1459 missing values generated)
{res}{txt}_2008M2 already numeric; no {res}replace
{txt}_2008M3 already numeric; no {res}replace
{txt}_2008Q2: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1445 missing values generated)
{res}{txt}_2008M4 already numeric; no {res}replace
{txt}_2008M5 already numeric; no {res}replace
{txt}_2008M6 already numeric; no {res}replace
{txt}_2008Q3 already numeric; no {res}replace
{txt}_2008M7 already numeric; no {res}replace
{txt}_2008M8 already numeric; no {res}replace
{txt}_2008M9 already numeric; no {res}replace
{txt}_2008Q4 already numeric; no {res}replace
{txt}_2008M10 already numeric; no {res}replace
{txt}_2008M11 already numeric; no {res}replace
{txt}_2008M12 already numeric; no {res}replace
{txt}_2009Q1: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1442 missing values generated)
{res}{txt}_2009M1 already numeric; no {res}replace
{txt}_2009M2 already numeric; no {res}replace
{txt}_2009M3 already numeric; no {res}replace
{txt}_2009Q2 already numeric; no {res}replace
{txt}_2009M4 already numeric; no {res}replace
{txt}_2009M5 already numeric; no {res}replace
{txt}_2009M6 already numeric; no {res}replace
{txt}_2009Q3 already numeric; no {res}replace
{txt}_2009M7 already numeric; no {res}replace
{txt}_2009M8 already numeric; no {res}replace
{txt}_2009M9 already numeric; no {res}replace
{txt}_2009Q4 already numeric; no {res}replace
{txt}_2009M10 already numeric; no {res}replace
{txt}_2009M11 already numeric; no {res}replace
{txt}_2009M12 already numeric; no {res}replace
{txt}_2010Q1 already numeric; no {res}replace
{txt}_2010M1 already numeric; no {res}replace
{txt}_2010M2 already numeric; no {res}replace
{txt}_2010M3 already numeric; no {res}replace
{txt}_2010Q2 already numeric; no {res}replace
{txt}_2010M4 already numeric; no {res}replace
{txt}_2010M5 already numeric; no {res}replace
{txt}_2010M6 already numeric; no {res}replace
{txt}_2010Q3 already numeric; no {res}replace
{txt}_2010M7 already numeric; no {res}replace
{txt}_2010M8 already numeric; no {res}replace
{txt}_2010M9 already numeric; no {res}replace
{txt}_2010Q4 already numeric; no {res}replace
{txt}_2010M10 already numeric; no {res}replace
{txt}_2010M11 already numeric; no {res}replace
{txt}_2010M12 already numeric; no {res}replace
{txt}_2011Q1: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1425 missing values generated)
{res}{txt}_2011M1: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1445 missing values generated)
{res}{txt}_2011M2 already numeric; no {res}replace
{txt}_2011M3 already numeric; no {res}replace
{txt}_2011Q2 already numeric; no {res}replace
{txt}_2011M4 already numeric; no {res}replace
{txt}_2011M5 already numeric; no {res}replace
{txt}_2011M6 already numeric; no {res}replace
{txt}_2011Q3 already numeric; no {res}replace
{txt}_2011M7 already numeric; no {res}replace
{txt}_2011M8 already numeric; no {res}replace
{txt}_2011M9 already numeric; no {res}replace
{txt}_2011Q4 already numeric; no {res}replace
{txt}_2011M10 already numeric; no {res}replace
{txt}_2011M11 already numeric; no {res}replace
{txt}_2011M12 already numeric; no {res}replace
{txt}_2012Q1 already numeric; no {res}replace
{txt}_2012M1 already numeric; no {res}replace
{txt}_2012M2 already numeric; no {res}replace
{txt}_2012M3 already numeric; no {res}replace
{txt}_2012Q2 already numeric; no {res}replace
{txt}_2012M4 already numeric; no {res}replace
{txt}_2012M5 already numeric; no {res}replace
{txt}_2012M6 already numeric; no {res}replace
{txt}_2012Q3 already numeric; no {res}replace
{txt}_2012M7 already numeric; no {res}replace
{txt}_2012M8 already numeric; no {res}replace
{txt}_2012M9 already numeric; no {res}replace
{txt}_2012Q4 already numeric; no {res}replace
{txt}_2012M10 already numeric; no {res}replace
{txt}_2012M11 already numeric; no {res}replace
{txt}_2012M12 already numeric; no {res}replace
{txt}_2013Q1 already numeric; no {res}replace
{txt}_2013M1 already numeric; no {res}replace
{txt}_2013M2 already numeric; no {res}replace
{txt}_2013M3 already numeric; no {res}replace
{txt}_2013Q2 already numeric; no {res}replace
{txt}_2013M4 already numeric; no {res}replace
{txt}_2013M5 already numeric; no {res}replace
{txt}_2013M6 already numeric; no {res}replace
{txt}_2013Q3 already numeric; no {res}replace
{txt}_2013M7 already numeric; no {res}replace
{txt}_2013M8 already numeric; no {res}replace
{txt}_2013M9 already numeric; no {res}replace
{txt}_2013Q4 already numeric; no {res}replace
{txt}_2013M10 already numeric; no {res}replace
{txt}_2013M11 already numeric; no {res}replace
{txt}_2013M12 already numeric; no {res}replace
{txt}_2014Q1: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1427 missing values generated)
{res}{txt}_2014M1: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1443 missing values generated)
{res}{txt}_2014M2 already numeric; no {res}replace
{txt}_2014M3 already numeric; no {res}replace
{txt}_2014Q2 already numeric; no {res}replace
{txt}_2014M4 already numeric; no {res}replace
{txt}_2014M5 already numeric; no {res}replace
{txt}_2014M6 already numeric; no {res}replace
{txt}_2014Q3 already numeric; no {res}replace
{txt}_2014M7 already numeric; no {res}replace
{txt}_2014M8 already numeric; no {res}replace
{txt}_2014M9 already numeric; no {res}replace
{txt}_2014Q4 already numeric; no {res}replace
{txt}_2014M10 already numeric; no {res}replace
{txt}_2014M11 already numeric; no {res}replace
{txt}_2014M12 already numeric; no {res}replace
{txt}_2015Q1 already numeric; no {res}replace
{txt}_2015M1 already numeric; no {res}replace
{txt}_2015M2 already numeric; no {res}replace
{txt}_2015M3 already numeric; no {res}replace
{txt}_2015Q2: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1430 missing values generated)
{res}{txt}_2015M4: all characters numeric; {res}replaced {txt}as {res}double
{txt}(1449 missing values generated)
{res}{txt}_2015M5 already numeric; no {res}replace
{txt}_2015M6 already numeric; no {res}replace
{txt}_2015Q3 already numeric; no {res}replace
{txt}_2015M7 already numeric; no {res}replace
{txt}_2015M8 already numeric; no {res}replace
{txt}_2015M9 already numeric; no {res}replace
{txt}_2015Q4 already numeric; no {res}replace
{txt}_2015M10 already numeric; no {res}replace
{txt}_2015M11 already numeric; no {res}replace
{txt}_2015M12 already numeric; no {res}replace
{txt}_2016Q1 already numeric; no {res}replace
{txt}_2016M1 already numeric; no {res}replace
{txt}_2016M2 already numeric; no {res}replace
{txt}_2016M3 already numeric; no {res}replace
{txt}_2016Q2 already numeric; no {res}replace
{txt}_2016M4 already numeric; no {res}replace
{txt}_2016M5 already numeric; no {res}replace
{txt}_2016M6 already numeric; no {res}replace
{txt}_2016Q3 already numeric; no {res}replace
{txt}_2016M7 already numeric; no {res}replace
{txt}_2016M8 already numeric; no {res}replace
{txt}_2016M9 already numeric; no {res}replace
{txt}_2016Q4 already numeric; no {res}replace
{txt}_2016M10 already numeric; no {res}replace
{txt}_2016M11 already numeric; no {res}replace
{txt}_2016M12 already numeric; no {res}replace
{txt}_2017Q1 already numeric; no {res}replace
{txt}_2017M1 already numeric; no {res}replace
{txt}_2017M2 already numeric; no {res}replace
{txt}_2017M3 already numeric; no {res}replace
{txt}_2017Q2 already numeric; no {res}replace
{txt}_2017M4 already numeric; no {res}replace
{txt}_2017M5 already numeric; no {res}replace
{txt}_2017M6 already numeric; no {res}replace
{txt}_2017Q3 already numeric; no {res}replace
{txt}_2017M7 already numeric; no {res}replace
{txt}_2017M8 already numeric; no {res}replace
{txt}_2017M9 already numeric; no {res}replace
{txt}_2017Q4 already numeric; no {res}replace
{txt}_2017M10 already numeric; no {res}replace
{txt}_2017M11 already numeric; no {res}replace
{txt}_2017M12 already numeric; no {res}replace
{txt}_2018Q1 already numeric; no {res}replace
{txt}_2018M1 already numeric; no {res}replace
{txt}_2018M2 already numeric; no {res}replace
{txt}_2018M3 already numeric; no {res}replace
{txt}_2018Q2 already numeric; no {res}replace
{txt}_2018M4 already numeric; no {res}replace
{txt}_2018M5 already numeric; no {res}replace
{txt}_2018M6 already numeric; no {res}replace
{txt}_2018Q3 already numeric; no {res}replace
{txt}_2018M7 already numeric; no {res}replace
{txt}_2018M8 already numeric; no {res}replace
{txt}_2018M9 already numeric; no {res}replace
{txt}_2018Q4 already numeric; no {res}replace
{txt}_2018M10 already numeric; no {res}replace
{txt}_2018M11 already numeric; no {res}replace
{txt}_2018M12 already numeric; no {res}replace
{txt}_2019Q1 already numeric; no {res}replace
{txt}_2019M1 already numeric; no {res}replace
{txt}_2019M2 already numeric; no {res}replace
{txt}_2019M3 already numeric; no {res}replace
{txt}_2019Q2 already numeric; no {res}replace
{txt}_2019M4 already numeric; no {res}replace
{txt}_2019M5 already numeric; no {res}replace
{txt}_2019M6 already numeric; no {res}replace
{txt}_2019Q3 already numeric; no {res}replace
{txt}_2019M7 already numeric; no {res}replace
{txt}_2019M8 already numeric; no {res}replace
{txt}_2019M9 already numeric; no {res}replace
{txt}_2019Q4 already numeric; no {res}replace
{txt}_2019M10 already numeric; no {res}replace
{txt}_2019M11 already numeric; no {res}replace
{txt}_2019M12 already numeric; no {res}replace
{txt}_2020Q1 already numeric; no {res}replace
{txt}_2020M1 already numeric; no {res}replace
{txt}_2020M2 already numeric; no {res}replace
{txt}_2020M3 already numeric; no {res}replace
{txt}_2020Q2 already numeric; no {res}replace
{txt}_2020M4 already numeric; no {res}replace
{txt}_2020M5 already numeric; no {res}replace
{txt}_2020M6 already numeric; no {res}replace
{txt}_2020Q3 already numeric; no {res}replace
{txt}_2020M7 already numeric; no {res}replace
{txt}_2020M8 already numeric; no {res}replace
{txt}_2020M9 already numeric; no {res}replace
{txt}_2020Q4 already numeric; no {res}replace
{txt}_2020M10 already numeric; no {res}replace
{txt}_2020M11 already numeric; no {res}replace
{txt}_2020M12 already numeric; no {res}replace
{txt}_2021Q1 already numeric; no {res}replace
{txt}_2021M1 already numeric; no {res}replace
{txt}_2021M2 already numeric; no {res}replace
{txt}_2021M3 already numeric; no {res}replace
{txt}_2021Q2 already numeric; no {res}replace
{txt}_2021M4 already numeric; no {res}replace
{txt}_2021M5 already numeric; no {res}replace
{txt}_2021M6 already numeric; no {res}replace
{txt}_2021Q3 already numeric; no {res}replace
{txt}_2021M7 already numeric; no {res}replace
{txt}_2021M8 already numeric; no {res}replace
{txt}_2021M9 already numeric; no {res}replace
{txt}_2021Q4 already numeric; no {res}replace
{txt}_2021M10 already numeric; no {res}replace
{txt}_2021M11 already numeric; no {res}replace
{txt}_2021M12 already numeric; no {res}replace
{txt}
{com}. /* Collapse to one observation per country and indicator */
> 
> collapse (firstnm) _*, by(Country_Code Indicator_Code) fast;
{res}{txt}
{com}. /* Fill missing month-end with quarter-end */
> 
> forval y = `=$year_min-1'/$year_max {c -(};
{txt}  2{com}.         forval q = 1/4 {c -(};
{txt}  3{com}.                 replace _`y'M`=3*`q'' = _`y'Q`q' if missing(_`y'M`=3*`q'');
{txt}  4{com}.         {c )-};
{txt}  5{com}. {c )-};
{txt}(21 real changes made)
(20 real changes made)
(21 real changes made)
(22 real changes made)
(19 real changes made)
(20 real changes made)
(22 real changes made)
(24 real changes made)
(23 real changes made)
(23 real changes made)
(24 real changes made)
(24 real changes made)
(25 real changes made)
(20 real changes made)
(21 real changes made)
(23 real changes made)
(23 real changes made)
(25 real changes made)
(23 real changes made)
(21 real changes made)
(24 real changes made)
(24 real changes made)
(24 real changes made)
(23 real changes made)
(23 real changes made)
(17 real changes made)
(20 real changes made)
(16 real changes made)
(17 real changes made)
(14 real changes made)
(18 real changes made)
(20 real changes made)
(21 real changes made)
(17 real changes made)
(17 real changes made)
(17 real changes made)
(18 real changes made)
(19 real changes made)
(19 real changes made)
(19 real changes made)
(20 real changes made)
(17 real changes made)
(15 real changes made)
(16 real changes made)
(13 real changes made)
(12 real changes made)
(17 real changes made)
(21 real changes made)
(13 real changes made)
(19 real changes made)
(16 real changes made)
(14 real changes made)
(14 real changes made)
(14 real changes made)
(18 real changes made)
(14 real changes made)
(9 real changes made)
(12 real changes made)
(15 real changes made)
(13 real changes made)
(15 real changes made)
(31 real changes made)
(15 real changes made)
(21 real changes made)
(16 real changes made)
(12 real changes made)
(17 real changes made)
(15 real changes made)
(10 real changes made)
(10 real changes made)
(10 real changes made)
(11 real changes made)
(14 real changes made)
(13 real changes made)
(10 real changes made)
(12 real changes made)

{com}. drop _*Q*;
{txt}
{com}. /* Keep year-end data */
> 
> keep Country_Code Indicator_Code _*M12;
{txt}
{com}. /* Reshape in long format */
> 
> reshape long _, i(Country_Code Indicator_Code) j(date) string;
{txt}(j = 2002M12 2003M12 2004M12 2005M12 2006M12 2007M12 2008M12 2009M12 2010M12 2011M12 2012M12 2013M12 2014M12 2015M12 2016M12 2017M12 2018M12 2019M12 2020M12 2021M12)

Data{col 36}Wide{col 43}->{col 48}Long
{hline 77}
Number of observations     {res}         695   {txt}->   {res}13,900      
{txt}Number of variables        {res}          22   {txt}->   {res}4           
{txt}j variable (20 values)                    ->   {res}date
{txt}xij variables:
         {res}_2002M12 _2003M12 ... _2021M12   {txt}->   {res}_
{txt}{hline 77}

{com}. reshape wide _, i(Country_Code date) j(Indicator_Code) string;
{txt}(j = ENDE_XDC_USD_RATE FIGB_PA FITB_PA FPOLM_PA PCPI_IX)

Data{col 36}Long{col 43}->{col 48}Wide
{hline 77}
Number of observations     {res}      13,900   {txt}->   {res}4,500       
{txt}Number of variables        {res}           4   {txt}->   {res}7           
{txt}j variable (5 values)    {res}Indicator_Code   {txt}->   (dropped)
xij variables:
                                      {res}_   {txt}->   {res}_ENDE_XDC_USD_RATE _FIGB_PA ... _PCPI_IX
{txt}{hline 77}

{com}. /* Merge country code */
> 
> merge m:1 Country_Code using Countries,
>         keepusing(country Yeuro)
>         keep(master match);
{res}
{txt}{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}             300
{txt}{col 9}from master{col 30}{res}             300{txt}  (_merge==1)
{col 9}from using{col 30}{res}               0{txt}  (_merge==2)

{col 5}Matched{col 30}{res}           4,200{txt}  (_merge==3)
{col 5}{hline 41}

{com}. keep if _merge==3 | Country_Code==163;
{txt}(280 observations deleted)

{com}.         /* 163 = euro area */
> 
> drop _merge;
{txt}
{com}. /* Rename variables */
> 
> foreach var in ENDE_XDC_USD_RATE FIGB_PA FITB_PA FPOLM_PA PCPI_IX {c -(};
{txt}  2{com}.         rename _`var' `var';
{txt}  3{com}. {c )-};
{res}{txt}
{com}. rename ENDE_XDC_USD_RATE fx;
{res}{txt}
{com}. rename PCPI_IX cpi;
{res}{txt}
{com}. /* Convert exchange rates to US$ per LCU */
> 
> replace fx = 1/fx;
{txt}(3,508 real changes made)

{com}. /* Convert interest rates to decimal */
> 
> foreach var of varlist FIGB_PA FITB_PA FPOLM_PA {c -(};
{txt}  2{com}.         replace `var' = `var'/100;
{txt}  3{com}. {c )-};
{txt}(1,098 real changes made)
(1,539 real changes made)
(1,521 real changes made)

{com}. /* Construct variables */
> 
> gen int year = real(substr(date,1,4));
{txt}
{com}. drop date;
{txt}
{com}. /* Construct dummy for euro area and Denmark */
> 
> gen byte Ieuro = Country_Code==163 | year>=Yeuro | country=="DNK";
{txt}
{com}. drop Yeuro;
{txt}
{com}. /* Common exchange rate and policy rate in the euro area */
> 
> sort year Ieuro country;
{txt}
{com}. foreach var of varlist fx FPOLM_PA {c -(};
{txt}  2{com}.         by year Ieuro: replace `var' = `var'[1] if Ieuro & Country_Code[1]==163;
{txt}  3{com}. {c )-};
{txt}(342 real changes made)
(186 real changes made, 8 to missing)

{com}. drop if Country_Code==163;
{txt}(20 observations deleted)

{com}. drop Ieuro;
{txt}
{com}. /* Construct dummy for USD countries */
> 
> gen byte Iusd = inlist(country,"USA","HKG");
{txt}
{com}. /* Common exchange rate and policy rate for USD countries */
> 
> sort year Iusd country;
{txt}
{com}. foreach var of varlist fx FPOLM_PA {c -(};
{txt}  2{com}.         by year Iusd: replace `var' = `var'[_N] if Iusd & country[_N]=="USA";
{txt}  3{com}. {c )-};
{txt}(20 real changes made)
(20 real changes made)

{com}. drop Iusd;
{txt}
{com}. /* Step 3: Merge national accounts and financial data */
> 
> merge 1:1 year Country_Code using `IMF_IFS',
>         nogen keep(master match);
{res}
{txt}{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}             300
{txt}{col 9}from master{col 30}{res}             300{txt}  
{col 9}from using{col 30}{res}               0{txt}  

{col 5}Matched{col 30}{res}           3,900{txt}  
{col 5}{hline 41}

{com}. drop Country_Code;
{txt}
{com}. /* Sample criteria */
> 
> keep if inrange(year,$year_min-1,$year_max+1);
{txt}(0 observations deleted)

{com}. /* Label variables */
> 
> order year country;
{txt}
{com}. label var year                  "Year";
{txt}
{com}. label var fx                    "Exchange rate (US$ per LCU)";
{txt}
{com}. label var FIGB_PA               "Government bond yield";
{txt}
{com}. label var FITB_PA               "Treasury bill rate";
{txt}
{com}. label var FPOLM_PA              "Central bank policy rate";
{txt}
{com}. label var cpi                   "Consumer price index";
{txt}
{com}. label var NCP_R_XDC             "Household consumption expenditure, Real index (LCU billion)";
{txt}
{com}. label var NCP_XDC               "Household consumption expenditure, Nominal (LCU billion)";
{txt}
{com}. label var NGDP_D_IX             "GDP, Deflator";
{txt}
{com}. label var NGDP_R_XDC    "GDP, Real index (LCU billion)";
{txt}
{com}. label var NGDP_XDC              "GDP, Nominal (LCU billion)";
{txt}
{com}. /* Save data */
> 
> sort year country;
{txt}
{com}. save IMF_IFS, replace;
{txt}{p 0 4 2}
file {bf}
IMF_IFS.dta{rm}
saved
{p_end}

{com}. log close;
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\myogo\Princeton Dropbox\Motohiro Yogo\Koijen Yogo - International\JPE\Replication\Code\1 Data\IMF_IFS.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}31 Oct 2025, 09:17:09
{txt}{.-}
{smcl}
{txt}{sf}{ul off}